package drds.binlog.sink;

import drds.binlog.common.AbstractLifeCycle;
import drds.binlog.filter.EventFilter;

import java.util.ArrayList;
import java.util.List;


public abstract class AbstractEventSink<T> extends AbstractLifeCycle implements EventSink<T>
{

    protected EventFilter eventFilter;
    protected List<EventDownStreamHandler> handlers = new ArrayList<EventDownStreamHandler>();

    public void addHandler(EventDownStreamHandler handler)
    {
        this.handlers.add(handler);
    }

    public EventDownStreamHandler getHandler(int index)
    {
        return this.handlers.get(index);
    }

    public void addHandler(EventDownStreamHandler handler, int index)
    {
        this.handlers.add(index, handler);
    }

    public void removeHandler(int index)
    {
        this.handlers.remove(index);
    }

    public void removeHandler(EventDownStreamHandler handler)
    {
        this.handlers.remove(handler);
    }

    public EventFilter getEventFilter()
    {
        return eventFilter;
    }

    public void setEventFilter(EventFilter eventFilter)
    {
        this.eventFilter = eventFilter;
    }

    public List<EventDownStreamHandler> getHandlers()
    {
        return handlers;
    }

    public void interrupt()
    {
        // do nothing
    }

}
